import Mock from 'mockjs'

let random = Mock.Random
// 列表
function getListData(number) {
	let data = []
	for (let i = 0; i < number; i++) {
		data.push({
			id: random.increment(),
			type: 'book',
			title: random.title(4, 10),
			cover: random.image(),
			coverType: random.integer(0, 2),
			labels: [
				{
					id: 1,
					name: '本站'
				}, 
				{
					id: 3,
					name: '原创'
				},
			],
			createTime: new Date(random.datetime()).getTime(),
			description: random.cparagraph(5, 30),
			author: random.cname(),
			likeNum: random.character('number'),
			readNum: random.character('number')
		})
	}
	
	return data
}

export default {
	getList: (data = { pageSie: 10 })=>{
		return {
			state: 200,
			method: 'get',
			code: 10000,
			requestId: random.string('lower', 15),
			path: '/book/list',
			message: '成功',
			error: '无效的身份信息',
			timestamp: random.now('yyyy-MM-dd HH:mm:ss.SSSZ'),
			data: getListData(data.pageSie)
		}
	}
}